<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateContentsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('contents', function (Blueprint $table) {
            $table->id();
//            $table->foreignId('article_id')->constrained()->onDelete('cascade');
            $table->foreignId('category_id')->constrained('categories')->onDelete('cascade');
            $table->string('title', 100)->nullable()->comment('标题');
            $table->string('url')->nullable()->comment('跳转链接');
            $table->text('content')->nullable()->comment('内容');
            $table->string('source', 30)->nullable()->comment('来源');
            $table->unsignedInteger('click')->nullable()->comment('点击数');
            $table->string('preview')->nullable()->comment('缩略图');
            $table->boolean('recommended')->default(false)->comment('是否推荐');
            $table->boolean('top')->default(false)->comment('是否置顶');
            $table->string('description')->nullable()->comment('文章介绍');
            $table->dateTime('publish_time')->nullable()->comment('发布时间');
            $table->text('fields')->nullable()->comment('扩展字段');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('contents');
    }
}
